package ua.eug.robov2.schematic;

import com.badlogic.gdx.utils.Array;

import ua.eug.robov2.robot.parts.RoboPart;
import ua.eug.robov2.schematic.chips.Chip;
import ua.eug.robov2.schematic.wire.Wire; 

public class Sheet {
		
	// Reference to chips
	Array<Chip> chips;
	// Reference to wires
	Array<Wire> wires;
	// Reference to robot parts
	Array<RoboPart> parts;

	public Sheet () {
		
		chips = new Array<Chip>(false,4);
		wires = new Array<Wire>(false,4);
		parts = new Array<RoboPart>(false,4);
		
	}

	// Heart of schematic - one step of signal operating
	public void act () {
		for (RoboPart p : parts)
			p.act();
		for (Chip c : chips)
			c.act();
		for (Wire w : wires)
			w.act();
	}
	
	public void addChip(Chip chip) {
		chips.add(chip);
	}

	public Boolean getWireState(int wIndex) {
		Wire w = wires.get(wIndex);
		if (w==null) return false;
		return w.inp.state;
	}
}
